#include <iostream>
#include "klog.h"
#include <assert.h>
#include <time.h>
#include <stdarg.h>

using namespace std;


void a(const char* fmt, ...) {
    va_list args;
    va_start(args, fmt);
    vfprintf(stderr, fmt, args);
    va_end(args);
}
void b(const char* fmt, ...) {
    va_list args;
    va_start(args, fmt);
    a(fmt, args);
    va_end(args);
}

int main(int argc, char** argv)
{
    assert(true);
    time_t t = time(NULL);
    char buf[100];
    strftime(buf, 100, "%Y-%m-%d", localtime(&t));

#if 0
    setLogFile(".", "test");
    //addSeqId(false);
    //addTime(false);
    //printf("%s", ctime(&t));
    //klog(LogInfo, "%s\n", ctime(&t));
    //a("%s\n", ctime(&t));
    //b("%s\n", ctime(&t));

    klog(LogInfo, "%s\n", "test");

    //printf("%s\n", buf);
    klog(LogInfo, "%s\n", buf);

    //printf("%5s%s\n", "4", ":");
    klog(LogInfo, "%5s%s\n", "323444", ":");

    klog(LogError, "Error: %s\n", "xx");
    klog(LogWarning, "Warning: %s\n", "waring");
    klog(LogDebug, "Debug: %s\n", "waring");
#else
    setLogFile(".", "test.log");
    setLogFileSize(1024*1024);
    setMaxLogFileNum(atoi(argv[1]));
    while (true) {
        kError("%s %s\n", "test", "error log");
        kWarning("%s %s\n", "test", "warning log");
        klog(LogInfo, "%s %s\n", "test", "info log");
        kDebug("%s %s\n", "test", "debug log");
        usleep(10);
    }
#endif

    return 0;
}
